home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / clonecd / September 93.img / Archives / Fun, Tricks & Hacks / Ümlåût Õmêléttè / ü.c < prev    next >
Text File  |  1992-05-13  |  797b  |  35 lines

  1. #define ACTIVE "aeiouACEOU"
  2. #define TRANSLATE "a6åàäâãá e4èéêë i4ìîíï o6øöôòóõ u4ùúûü A4ÅÀÄàC1Ç E1É O2ÖÕ U1Ü "
  3.  
  4. void
  5. Umlaut(register char *buffer,int len)
  6. {    char            *table = TRANSLATE, *active = ACTIVE;
  7.     register char    *tp;
  8.     register int    i,j,v,count;
  9.     
  10.     v = 0;
  11.     
  12.     for (i = 0; i < len; i++)
  13.     {    // Update the random number        // Rotate left by one & xor in char
  14.         if (v < 0)
  15.             v = ((v << 1) ^ buffer[i]) + 1;
  16.         else
  17.             v = ((v << 1) ^ buffer[i]);            
  18.         
  19.         // Find if this is an active character
  20.         for (j = 0; j < sizeof(ACTIVE) - 1; j++)
  21.             if (active[j] == buffer[i])
  22.                 break;
  23.         
  24.         if (j < sizeof(ACTIVE) - 1)        // Done right
  25.         {    tp = table;
  26.             while (*tp != buffer[i])
  27.             {    while (*tp != ' ')
  28.                     tp++;
  29.                 tp++;
  30.             }
  31.             count = tp[1] - '0';
  32.             buffer[i] = tp[2+((v & 0x7FFFFFFF)%count)];
  33.         }
  34.     }    
  35. }